﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria.GameInput;

namespace Terraria
{
	// Token: 0x0200004D RID: 77
	public class TestHighFPSIssues
	{
		// Token: 0x060006C3 RID: 1731 RVA: 0x0036AA28 File Offset: 0x00368C28
		public static void TapUpdate(GameTime gt)
		{
			TestHighFPSIssues._tapUpdates.Add(gt.TotalGameTime.TotalMilliseconds);
			TestHighFPSIssues.conD = 0;
			TestHighFPSIssues.race--;
			if (++TestHighFPSIssues.conU > TestHighFPSIssues.conUH)
			{
				TestHighFPSIssues.conUH = TestHighFPSIssues.conU;
			}
		}

		// Token: 0x060006C4 RID: 1732 RVA: 0x0036AA80 File Offset: 0x00368C80
		public static void TapUpdateEnd(GameTime gt)
		{
			TestHighFPSIssues._tapUpdateEnds.Add(gt.TotalGameTime.TotalMilliseconds);
		}

		// Token: 0x060006C5 RID: 1733 RVA: 0x0036AAA8 File Offset: 0x00368CA8
		public static void TapDraw(GameTime gt)
		{
			TestHighFPSIssues._tapDraws.Add(gt.TotalGameTime.TotalMilliseconds);
			TestHighFPSIssues.conU = 0;
			TestHighFPSIssues.race++;
			if (++TestHighFPSIssues.conD > TestHighFPSIssues.conDH)
			{
				TestHighFPSIssues.conDH = TestHighFPSIssues.conD;
			}
		}

		// Token: 0x060006C6 RID: 1734 RVA: 0x0036AB00 File Offset: 0x00368D00
		public static void Update(GameTime gt)
		{
			if (PlayerInput.Triggers.Current.Down)
			{
				TestHighFPSIssues.race = (TestHighFPSIssues.conUH = (TestHighFPSIssues.conDH = 0));
			}
			double totalMilliseconds = gt.TotalGameTime.TotalMilliseconds;
			double num = totalMilliseconds - 5000.0;
			while (TestHighFPSIssues._tapUpdates.Count >= 0)
			{
				if (TestHighFPSIssues._tapUpdates.Count != 0)
				{
					if (TestHighFPSIssues._tapUpdates[0] < num)
					{
						goto IL_168;
					}
				}
				while (TestHighFPSIssues._tapDraws.Count >= 0)
				{
					if (TestHighFPSIssues._tapDraws.Count != 0)
					{
						if (TestHighFPSIssues._tapDraws[0] < num)
						{
							TestHighFPSIssues._tapDraws.RemoveAt(0);
							continue;
						}
					}
					while (TestHighFPSIssues._tapUpdateEnds.Count > 0 && TestHighFPSIssues._tapUpdateEnds[0] < num)
					{
						TestHighFPSIssues._tapUpdateEnds.RemoveAt(0);
					}
					Main.versionNumber = string.Concat(new object[]
					{
						"total (u/d)   ",
						TestHighFPSIssues._tapUpdates.Count,
						" ",
						TestHighFPSIssues._tapUpdateEnds.Count,
						"  ",
						TestHighFPSIssues.race,
						" ",
						TestHighFPSIssues.conUH,
						" ",
						TestHighFPSIssues.conDH
					});
					Main.NewText(Main.versionNumber, byte.MaxValue, byte.MaxValue, byte.MaxValue, false);
					return;
				}
				IL_168:
				TestHighFPSIssues._tapUpdates.RemoveAt(0);
			}
		}

		// Token: 0x04000CD6 RID: 3286
		private static List<double> _tapUpdates = new List<double>();

		// Token: 0x04000CD7 RID: 3287
		private static List<double> _tapUpdateEnds = new List<double>();

		// Token: 0x04000CD8 RID: 3288
		private static List<double> _tapDraws = new List<double>();

		// Token: 0x04000CD9 RID: 3289
		private static int conU = 0;

		// Token: 0x04000CDA RID: 3290
		private static int conUH = 0;

		// Token: 0x04000CDB RID: 3291
		private static int conD = 0;

		// Token: 0x04000CDC RID: 3292
		private static int conDH = 0;

		// Token: 0x04000CDD RID: 3293
		private static int race = 0;
	}
}
